<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>教师信息管理</title>
<!-- 引入easyui 的主题样式  和  easyui 提供的图标样式 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css" />
<!-- 引入jquery 和  easyui.js   中文设置js-->
<script type="text/javascript"
	src="${pageContext.request.contextPath}\js\jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
$(function(){
	//名字查询
	$('#tb').textbox({        
	    iconCls:'icon-man', 
	    iconAlign:'left',
	    prompt:'输入相关课题信息，点击下列搜索按钮查询，如：姓名，院系，课题名称等',
	    width:1136,
	    height:30
	})

	
	//展示的表格
	$('#dg').datagrid({ 		
		//title:'显示全部信息',
		 url:'showallcourse',  
		striped:true,
	    columns:[[    
	              {field:'co',checkbox:'true',title:'Code',align:'center'},    
	              {field:'cid',title:'课题标号',width:100,align:'center'},    
	              {field:'cname',title:'课题名称',width:100,align:'center'},    
	              {field:'cstate',title:'选择状态',width:100,align:'center'},
	              {field:'tid',title:'教师编号',width:100,align:'center'},
	              {field:'tname',title:'教师名字',width:100,align:'center'},    
	              {field:'tdepart',title:'院系',width:100,align:'center'},    
	              {field:'tprofe',title:'职称',width:100,align:'center'},
	              {field:'ttel',title:'教师电话',width:100,align:'center'}        
	    ]],
	    pagination:true,
	    pagePosition:'bottom',
	    rownumbers:true,
	    pageNumber:1,
	    pageSize:2,
	    pageList:[5,10,15],
	    
	    toolbar: [{
				iconCls: 'icon-search',
				text:"搜 索 ",
				handler: function(){
					var tinfo=$('#tb').textbox('getValue');
						$('#dg').datagrid({			
							 url:'tinfosearchcourse', 							
							 queryParams: {
									info: tinfo,									
								}					
						})					
				}				
			},'—',{
				iconCls: 'icon-cut',
				text:"修改",
				handler: function(){					
					var row=$('#dg').datagrid('getChecked');				
					if(row.length==1){
						$("#form").show();
						$('#win').window({
							title:'编辑课题信息',
						    width:600,    
						    height:400,    
						    modal:true   
						});						
						//确定修改按钮
						$('#btn').linkbutton({    
						    iconCls: 'icon-ok',	    
						    onClick:function(){						    						    	
						    	 var cname=$('#tb1').textbox('getValue');						   
						    	 var tid=$('#tb3').textbox('getValue');
								 var cstate=$('#cc').combobox('getValue');						    	
						    	 var cid=row[0].cid;						    						    	
						    	$.ajax({
						    		url:'adminupdatecourse',
						    		type:'post',
						    		data:{
						    			'cname':cname,
						    	         'cstate':cstate,
						    			'tid':tid,
						    			'cid':cid,
						    		},
						    	    datatype:'text',
						    		success:function(data){
						    			if(data==1){
						    				$.messager.alert('提示','修改成功');
						    				$('#win').window({
						    					closed:true,//关闭窗口
						    				});
						    				$('#dg').datagrid('reload');
						    			}else{
						    				$.messager.alert('提示','修改失败');   
						    				$('#tb1').textbox('clear');
						    				$('#tb3').textbox('clear');
						    			}
						    		}
						    	})						    	
						    }						    						  						    
						}); 						
						//重置修改的内容
						$('#btn1').linkbutton({    
							iconCls: 'icon-clear',
								onClick:function(){	
									$('#tb1').textbox('clear');
				    				$('#tb3').textbox('clear');
								}
						});  						
					}else{						
						$.messager.alert('提示','请选择一条进行修改');    						
					}
				}			
			},'-',{
				iconCls: 'icon-search',
				text:"审核课题",
				handler: function(){
					$("#t1").hide();
					$("#t2").show();
					$('#dg2').datagrid({    
						title:'待审核的课题',
					    url:'showWaitAuditingCourse',    
					    columns:[[    
					        {field:'co',checkbox:'true',title:'Code',align:'center'},  
					        {field:'appid',title:'申请编号',width:100,align:'center'},    
					        {field:'appcontent',title:'申请课题名称',width:100,align:'center'},    
					        {field:'apptime',title:'申请时间',width:100,align:'center'},
					        {field:'appstate',title:'申请状态',width:100,align:'center'},
					        {field:'tname',title:'教师姓名',width:100,align:'center'},
					        {field:'tid',title:'教师编号',width:100,align:'center'},    
					        {field:'tdepart',title:'院系',width:100,align:'center'}, 
					        {field:'tprofe',title:'职称',width:100,align:'center'}, 
					        {field:'ttel',title:'联系电话',width:100,align:'center'} 
					    ]],
					    pagination:true,
					    pagePosition:'bottom',
					    rownumbers:true,
					    pageNumber:1,
					    pageSize:2,
					    pageList:[5,10,15],					    
					    toolbar: [{
								iconCls: 'icon-ok',
								text:"审核 ",
								handler: function(){
									var a=$('#dg2').datagrid('getSelections');

									if(a.length==1){																

										var appid=a[0].appid;
										var appcontent=a[0].appcontent;
										var tid=a[0].tid;
										$.ajax({
											url:'AuditingCourse',
											type:'post',
											data:{'appid':appid,
												'appcontent':appcontent,
												'tid':tid,
												},
											datatype:'text',
											success:function(data){
												if(data==1){
													$.messager.alert('提示','审核成功'); 
													$('#dg2').datagrid('reload');
													}else{													
														$.messager.alert('提示','审核失败');   														
													}																																		
											}																						
										})								
									}else{										
										$.messager.alert('提示','请选择一行');    
									}									
								}													    
					    },'-',{					    	
					    	iconCls: 'icon-undo',
							text:"返回",
							handler: function(){
								$("#t2").hide();
								$("#t1").show();																
							}					    	
					    }]					
					});
					},									
			}]      
	});  
		
	//课题名称
	$('#tb1').textbox({    	        
	    prompt:'请输入新的课题名称'	    
	})
	//教师编号
	$('#tb3').textbox({    	         
	    prompt:'请输入新的教师编号'
	})	
	
	//隐藏文本修改框
	$("#form").hide();	
	
	
	
	
	

})
</script>
<body>



<div id="t1">
<!-- 表格展示课题信息 -->
<table id="dg">
<!--查询输入框-->
<input id="tb" type="text" style="width:300px">
</table> 
</div>
 
 <!--修改信息窗口-->
<div id="win">
<div id="form">
<form style="margin-top:50px">
<div style="margin-left:100px"><span>课题名称:</span>&nbsp;<input id="tb1" type="text" style="width:300px;height:50px"></div><br>
<!-- 课题状态 -->
<div style="margin-left:100px"><span>课题状态:</span>&nbsp;<select id="cc" class="easyui-combobox" name="dept" style="width:300px;height:50px">   
    <option>false</option>   
    <option>true</option>     
</select></div><br>
<div style="margin-left:100px"><span>教师编号:</span>&nbsp;<input id="tb3" type="text" style="width:300px;height:50px"></div><br>
<a id="btn" href="#" style="margin-left:155px;width:100px;height:40px">确定</a> 
<a id="btn1" href="#" style="margin-left:100px;width:100px;height:40px">重置</a>
</form>
</div>
</div> 



<!-- 审核课题 -->
<div id="t2">
<table id="dg2"></table>  
</div>


 
</body>
</html>